package com.hbfu.zggdwlzzsx.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hbfu.zggdwlzzsx.entity.Authors;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AuthorMapper extends BaseMapper<Authors> {

    @Select("select * from authors where id=#{id}")
    @Results({
            @Result(column = "id", property = "id"),
            @Result(column = "name", property = "name"),
            @Result(column = "name", property = "works", javaType = List.class,
                    many = @Many(select = "com.hbfu.zggdwlzzsx.mapper.WorkMapper.getWorkByAuthorName")),
            @Result(column = "introduction", property = "introduction"),
            @Result(column = "picture", property = "picture")
    })
    Authors getById(Integer id);

    @Select("select * from authors")
    List<Authors> getAllAuthors();
}
